package com.itkaien.AopAnno.advice;

import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.stereotype.Component;

@Component
public class MyadviceAnno2 implements MethodBeforeAdvice, AfterReturningAdvice, MethodInterceptor {


    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println("Myadvice2 afterReturning");
    }

    @Override
    public void before(Method method, Object[] args, Object target) throws Throwable {
        System.out.println("Myadvice2 before");
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        System.out.println("Myadvice2 invoke Before");
        // 执行目标方法
        Object result = invocation.proceed();
        System.out.println("Myadvice2 invoke After");
        return result;
    }
}
